package com.fenghongzhang.kotlin1903.goods

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.fenghongzhang.kotlin1903.R
import kotlinx.android.synthetic.main.title_layout.view.*

class GoodsAdapter(mutableList: MutableList<Goods>) : BaseMultiItemQuickAdapter<Goods,BaseViewHolder>(mutableList){

    init {
        addItemType(Const.TITLE, R.layout.title_layout)
        addItemType(Const.Content, R.layout.content_layout)
    }

    override fun convert(helper: BaseViewHolder, item: Goods) {
        when(helper.itemViewType){
            Const.TITLE ->{
                helper.setText(R.id.title,item.goods_desc)
                helper.addOnClickListener(R.id.title)
            }
            Const.Content ->{
                helper.setText(R.id.num,item.goods_count)
                helper.addOnClickListener(R.id.name)
                helper.addOnClickListener(R.id.checkbox)
                helper.addOnClickListener(R.id.add)
                helper.addOnClickListener(R.id.sub)
            }
        }

    }

}
